﻿#region License

/*
 © 2012 Alex Kazaev
 * FolderDrive project [http://folderdrive.codeplex.com/]
 * Licensed under Ms-PL license [http://www.opensource.org/licenses/MS-PL]
 */

#endregion License

using System.Configuration;

namespace FolderDrive.Configuration
{
  /// <summary>
  /// Configuration section for storing all the app parameters
  /// </summary>
  internal class FolderDriveConfigurationSection : ConfigurationSection
  {
    #region ConfigurationProperty instances

    private static readonly ConfigurationProperty propFolderDriveConfiguration = new ConfigurationProperty("drives",
                                                                                                           typeof(FolderDriveConfigurationElementCollection),
                                                                                                           null,
                                                                                                           ConfigurationPropertyOptions.IsDefaultCollection);

    private static readonly ConfigurationProperty startMinimized = new ConfigurationProperty("startMinimized", typeof(bool), true);
    private static readonly ConfigurationProperty unmountOnExit = new ConfigurationProperty("unmountOnExit", typeof(bool), true);
    private static readonly ConfigurationProperty showTooltip = new ConfigurationProperty("showTooltip", typeof(bool), true);
    private static readonly ConfigurationProperty checkUpdates = new ConfigurationProperty("checkUpdates", typeof(bool), true);
    private static readonly ConfigurationProperty minOnClose = new ConfigurationProperty("minOnClose", typeof(bool), false);

    #endregion ConfigurationProperty instances

    #region fields

    private static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();

    #endregion fields

    #region properties

    /// <summary>
    /// Gets the drives mappings.
    /// </summary>
    [ConfigurationProperty("drives", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
    public FolderDriveConfigurationElementCollection Drives
    {
      get { return (FolderDriveConfigurationElementCollection)base[propFolderDriveConfiguration]; }
    }

      /// <summary>
      /// Gets or sets the check updates flag value.
      /// </summary>
    [ConfigurationProperty("checkUpdates", DefaultValue = true)]
    public bool CheckUpdates
    {
        get { return (bool)base[checkUpdates]; }
        set { base[checkUpdates] = value; }
    }

    /// <summary>
    /// Gets or sets the start minimized flag.
    /// </summary>
    [ConfigurationProperty("startMinimized", DefaultValue = true)]
    public bool StartMinimized
    {
      get { return (bool)base[startMinimized]; }
      set { base[startMinimized] = value; }
    }

    /// <summary>
    /// Gets or sets the unmount on exit flag.
    /// </summary>
    [ConfigurationProperty("unmountOnExit", DefaultValue = true)]
    public bool UnmountOnExit
    {
      get { return (bool)base[unmountOnExit]; }
      set { base[unmountOnExit] = value; }
    }

    /// <summary>
    /// Gets or sets the show tooltip flag.
    /// </summary>
    [ConfigurationProperty("showTooltip", DefaultValue = true)]
    public bool ShowTooltip
    {
      get { return (bool)base[showTooltip]; }
      set { base[showTooltip] = value; }
    }

    /// <summary>
    /// Gets or sets the show tooltip flag.
    /// </summary>
    [ConfigurationProperty("minOnClose", DefaultValue = false)]
    public bool MinOnClose
    {
        get { return (bool)base[minOnClose]; }
        set { base[minOnClose] = value; }
    }
    #endregion properties

    #region constructor

    /// <summary>
    /// Initializes the <see cref="FolderDriveConfigurationSection"/> class.
    /// </summary>
    static FolderDriveConfigurationSection()
    {
      properties.Add(propFolderDriveConfiguration);
      properties.Add(startMinimized);
      properties.Add(unmountOnExit);
      properties.Add(showTooltip);
      properties.Add(checkUpdates);
      properties.Add(minOnClose);
    }

    #endregion constructor
  }
}